// 登录验证
// 调接口进行if判断,判断权限
function log(){
    var acc=document.querySelector("#account")
    var pwd=document.querySelector(".pwd")
    let login={
        userAccount:acc.value,
        userPassword:pwd.value
    }
    ajaxHttp("post","login/toLogin",login).then((res)=>{
        // console.log(res);
        res=JSON.parse(res)
       if(res.code===200){
        var data=res.dataset.userId
        var userName=res.dataset.userName
        var proid=res.dataset.projectId
        var role=res.dataset.userRole
        localStorage.setItem("userid",data)
        localStorage.setItem("userName",userName)
        localStorage.setItem("userRole",role)
        var user=res.dataset.userRole
            alert("登录成功")
            if(user==="0"){
                alert("您已超级管理员登录")
                localStorage.setItem("projectid",proid)
            }else if(user==="1"){
                alert("您以管理员身份登录")
                localStorage.setItem("projectid",proid)
            }else if(user==="2"){
                alert("您以老师的身份登录")
                localStorage.setItem("projectid",proid)
            }else if(user==="3"){
                alert("您已学生的身份登录")
                localStorage.setItem("projectid",proid)
            }
            location.href="home.html"
       }else if(res.code===500){
        alert("账号或者密码错误")
       }
    })
}